package com.my.study.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: yidujun
 * @create: 2021/04/13 13:58
 */
public final class DateUtil {

    public static Date parseDate(String date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        try {
            return format.parse(date);
        } catch (ParseException e) {
            throw new RuntimeException("日期转化错误");
        }
    }

    public static String format(Date parseDate, String s) {
        SimpleDateFormat format = new SimpleDateFormat(s);
        return format.format(parseDate);
    }
}
